package jsd2302.src.io;

import java.io.*;
import java.nio.charset.StandardCharsets;

/**
 * */
public class Test {
    public static void main(String[] args) throws IOException {
        FileOutputStream fos=new FileOutputStream("demo.txt");
        FileInputStream fis=new FileInputStream("demo.txt");
      for(int i=97;i<123;i++){
          fos.write(i);
      }
      fos.close();
        System.out.println("写入完毕！");
    }
}
class Test1{
    public static void main(String[] args) throws IOException {
        File file=new File("demo.txt");
        FileInputStream fis=new FileInputStream("demo.txt");
        byte[] data=new byte[(int)file.length()];//创建与文件等长的字节数组
        fis.read(data);//一次性读取数据到data中
        String line=new String(data, StandardCharsets.UTF_8);//将data中的字节还原为字符串
        System.out.println(line);
        fis.close();
    }
}
